package com.example.fresheveryday.mapper;

import com.example.fresheveryday.po.Permission;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author ll
 * @since 2023-07-05
 */
@Mapper
public interface PermissionMapper extends BaseMapper<Permission> {
    @Select("select permission.permission_name from user " +
            "inner join user_role on user.id = user_role.uid " +
            "inner join role on user_role.rid = role.role_id " +
            "inner join role_permission on role.role_id = role_permission.rid " +
            "inner join permission on role_permission.pid = permission.permission_id " +
            "where user.id = #{userId}")
    public Set<String> queryPermissionByUserId(String userId);
}
